%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This file is part of the book
%%
%% Algorithmic Graph Theory
%% http://code.google.com/p/graphbook/
%%
%% Copyright (C) 2009--2013 Minh Van Nguyen <mvngu.name@gmail.com>
%%
%% See the file COPYING for copying conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{algorithmic}[1]
%% input and output
\Require Two integers $a > 0$ and $b \geq 0$ with $a \geq b$.
\Ensure The greatest common divisor of $a$ and $b$.
%%
%% algorithm body
\State $x \gets a$
\State $y \gets b$
\While{$y \neq 0$}
  \State $r \gets x \bmod y$
  \State $x \gets y$
  \State $y \gets r$
\EndWhile
\State \Return $x$
\end{algorithmic}
